package com.xpxrule.function;

import com.googlecode.aviator.runtime.function.AbstractFunction;

import java.util.concurrent.ConcurrentHashMap;

public class AviatorCustomFunctionContext {
    private static ConcurrentHashMap<String, AbstractFunction> customFunctionMap;

    public static class CustomFunctionName {
        public static final String BIG_DECIMAL_EQUAL = "bigDecimalEqual";
        public static final String BIG_DECIMAL_NOT_EQUAL = "bigDecimalNotEqual";
        public static final String BIG_DECIMAL_GREATER_THAN = "bigDecimalGreaterThan";
        public static final String BIG_DECIMAL_GREATER_THAN_OR_EQUAL = "bigDecimalGreaterThanOrEqual";
        public static final String BIG_DECIMAL_LESS_THAN = "bigDecimalLessThan";
        public static final String BIG_DECIMAL_LESS_THAN_OR_EQUAL = "bigDecimalLessThanOrEqual";
    }

    static {
        customFunctionMap = new ConcurrentHashMap<>();
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_EQUAL, new BigDecimalEqualFunction());
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_NOT_EQUAL, new BigDecimalNotEqualFunction());
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_GREATER_THAN, new BigDecimalGreaterThanFunction());
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_GREATER_THAN_OR_EQUAL, new BigDecimalGreaterThanOrEqualFunction());
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_LESS_THAN, new BigDecimalLessThanFunction());
        customFunctionMap.put(CustomFunctionName.BIG_DECIMAL_LESS_THAN_OR_EQUAL, new BigDecimalLessThanOrEqualFunction());
    }

    public static ConcurrentHashMap<String, AbstractFunction> getCustomFunctionMap() {
        return customFunctionMap;
    }
}
